﻿using UnityEngine;
using System.Collections;

public class Vortex : MonoBehaviour {

    public Vector3 vortexLocation = Vector3.zero;
    public float gravataionalSpeed = .5f;
    public GameObject blackHole;
	// Use this for initialization
	
	
	
	void Start () 
    {
 
	}
	
	// Update is called once per frame
	void Update () 
    {
	 
		
        transform.position = Vector3.MoveTowards(transform.position, vortexLocation, Time.deltaTime * gravataionalSpeed);
        if (transform.position == vortexLocation)
        {
            AIBase Die;
            if ((Die = gameObject.GetComponent<AIBase>()) != null)
            {
                PauseMenu.enemiesKilled++;
                Die.Die();
            }

            else
            {
                Destroy(gameObject);
            }
        }
        else if (blackHole == null)
        {
            Destroy(this);
        }
    }
}
